package com.miaostars.myaifriend;

import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Arrays;

public class DialogueGUI {
    private final Player player;
    private final VoiceManager voiceManager;

    public DialogueGUI(Player player, VoiceManager voiceManager) {
        this.player = player;
        this.voiceManager = voiceManager;
    }

    public void open() {
        Inventory inv = Bukkit.createInventory(null, 27, "语音对话");
        
        // 麦克风按钮
        ItemStack mic = new ItemStack(Material.REDSTONE_TORCH);
        ItemMeta meta = mic.getItemMeta();
        meta.setDisplayName("§a按住说话");
        meta.setLore(Arrays.asList("§7长按此按钮与AI对话"));
        mic.setItemMeta(meta);
        inv.setItem(13, mic);
        
        player.openInventory(inv);
    }

    // 在事件监听器中调用
    public static void onItemHold(Player player) {
        // 模拟语音采集（实际需客户端模组支持）
        byte[] audioData = /* 从客户端获取录音数据 */;
        voiceManager.processVoice(player, audioData);
    }
}